package jin.si.com.web;

import jin.si.com.entity.*;
import jin.si.com.service.UserOrderService;
import jin.si.com.utils.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @description: 用户订单信息查询
 * @ClassName UserOrderController
 * @Author MT
 * @Date 2021/5/14 10:22
 **/


@Controller
@RequestMapping("/userOr")
public class UserOrderController {
    @Autowired
    private UserOrderService service;

    //一对一 订单对用户
    @RequestMapping("/getUserOrder")
    @ResponseBody
    public R06Order_Vo getUserOrder(int id){
        R06Order_Vo user=service.getUserOrder(id);
        return user;
    }

    //一对多 用户对订单
    @RequestMapping("/getUserOrderList")
    @ResponseBody
    public JsonData getUserOrderList(int id){
        R06User_Vo list=service.getUserOrderList(id);
        return list!=null?JsonData.buildSuccess(list):JsonData.buildError("服务器出问题了");
    }

    //多对多 用户对商品
    @RequestMapping("/getUserProductList")
    @ResponseBody
    public JsonData getUserProductList(int id){
       UserVo user=service.getUserProductList(id);
       return  user!=null?JsonData.buildSuccess(user):JsonData.buildError("服务器出错了");
    }

    //多对多 商品对用户
    @RequestMapping("/getProductUserList")
    @ResponseBody
    public JsonData getProductUserList(int id){
        ProductVo2 product=service.getProductUserList(id);
        return  product!=null?JsonData.buildSuccess(product):JsonData.buildError("服务器出错了");
    }



    //懒加载 一对多 用户对订单
    @RequestMapping("/getUserOrder1")
    @ResponseBody
    public JsonData getUserOrder1(){
        List<UserVo1> list=service.getUserOrder1();
        return list!=null?JsonData.buildSuccess(list):JsonData.buildError("服务器出问题了");
    }

    //懒加载 一对一 订单对用户
    @RequestMapping("/getOrderUser1")
    @ResponseBody
    public JsonData getOrderUser1(){
        List<OrderVo2>  list=service.getOrderUser1();
        return list!=null?JsonData.buildSuccess(list):JsonData.buildError("服务器出问题了");
    }









}
